<!--
  #%L
  thinkbig-ui-operations-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<card-layout class="right-card">
    <header-section layout="row" >
        <ng-md-icon icon="error_outline" size="20"
                   class="error right-card-title-text">
        </ng-md-icon><div class="card-title right-card-title-text" style="padding-left:5px;">{{"views.alerts-template.Alerts" | translate}}</div>
        <span flex></span>
    </header-section>
    <body-section>
        <md-divider></md-divider>
        <md-list layout="column" flex class="md-2-line">
            <md-list-item layout-row layout-align="start end" ng-repeat="alert in vm.alerts|orderBy:'-lastAlertTimestamp' "  ng-click="vm.navigateToAlerts(alert)" ng-init="vDN = 'views.alerts-template.' + alert.typeDisplayName">
                <md-icon class="push-left-md error">warning</md-icon>
                <div class="md-list-item-text pad pull-left-md" flex >
                    <div layout="row" flex="100" layout-align="start space-between">
                    <div layout="column" flex="50" layout-align="start">
                        <span class="text-truncate alert-heading">{{alert.groupDisplayNameTruncated}}</span>
                        <span class="text-truncate alert-description" >{{vDN | translate}}</span>
                    </div>
                    <div layout="column" flex layout-align="end end">
                        <span class="alert-heading"> {{alert.since}}</span>
                        <span class="alert-description" ng-if="alert.count ==1"  >{{alert.count}} {{"views.alerts-template.ALERT1" | translate}}</span>
                        <span class="alert-description"   ng-if="alert.count > 1 && alert.count < 5"  >{{alert.count}} {{"views.alerts-template.ALERT2" | translate}}</span>
                        <span class="alert-description"  ng-if="alert.count > 4"  >{{alert.count}} {{"views.alerts-template.ALERT5" | translate}}</span>
                    </div>
                    </div>
                </div>
                <md-divider *ngIf="!$last"></md-divider>
            </md-list-item>
            <md-list-item ng-if="vm.alerts.length == 0">
                <div style="width:100%" class="item-column" >
                    <span class="item-title" >{{"views.alerts-template.Na" | translate}}</span>
                    </div>
            </md-list-item>
        </md-list>
    </body-section>
</card-layout>
